home *** CD-ROM | disk | FTP | other *** search
- Path: news.ichange.com!newsmaster
- From: Jesse Liberty <jl@staff.ichange.com>
- Newsgroups: comp.lang.c++
- Subject: Re: private base class vs. private member object
- Date: Sat, 09 Mar 1996 13:17:34 -0500
- Organization: AT&T New Media Services
- Message-ID: <3141CB3E.5A36@staff.ichange.com>
- References: <4hpqq9$9o3@hackberry.zilker.net> <4hrl32$4b3@newsgate.dircon.co.uk>
- NNTP-Posting-Host: 198.112.128.208
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Rob and Sylvia Worsnop wrote:
- > If you want to access protected methods use private inheritance.
- > Some people just use private inheritance anyway because the code
- > is often cleaner.
- > Whether you use private member objects or private inheritance doesn't
- > matter a great deal. The really important thing is not to confuse
- > public inheritance and private inheritance.
-
- If I understand what you've written, I think I disagree <smile>.
-
- Private inheritance has a specific meaning: it allows you to provide
- "implemented in terms of." That is, when you want to inherit
- implementation but not interface, private inheritance is the solution.
-
- Note that an alternative solution in many cases is to use delegation
- through contained classes. The advantage of private inheritance over
- containment is access to protected members, and perhaps that is what you
- meant, but containment offers other advantages (including the ability to
- have multiple instances of the contained class).
-
-
-
-
- --
- Jesse Liberty. (AT&T New Media Services) jl@staff.ichange.com
- Teach Yourself C++ In 21 Days. SAMS, 1994
- Teach Yourself MORE C++ In 21 Days. SAMS, 1996
- Teach Yourself ANSI C++ In 21 Days. SAMS, 1996
- C++: An Introduction To Programming. QUE, 1996
-